/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include "../节点.h"

#include <字符串转换.h>
#include <纹理/纹理.h>
#include <物体/物体.h>
#include <材质/材质.h>

#include "节点数据声明.h"



class C_图像插座 : public C_插座基类 {
public:
	C_图像插座(std::wstring name);
	~C_图像插座();

	S_插座图像数据	m_像素;

	void*		f_getData(uint8 线程ID);
	void		f_setData(void* data, int64 ID = -1, uint8 线程ID = 0);


	void	f_读取(FILE* f);
	void	f_写入(FILE* f);

	std::wstring		f_getTypeName() { return L"image"; }
};

#define DEF_图像插座(socket) dynamic_cast<C_图像插座*>( (socket) )
#define DEF_图像插座Value(socket)  ((S_插座图像数据*)( (socket)->f_getData(0)) )

#define DEF_创建图像插座_I(name)  socket = new C_图像插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建图像插座_O(name)  socket = new C_图像插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);






class C_纹理插座 : public C_插座基类 {
	vec3 m_Value;
	S_纹理 m_内部空纹理;
public:
	C_纹理插座(std::wstring name, S_设备环境& ctx);
	~C_纹理插座();

	S_纹理*				m_Tex;

	virtual void*	f_getData(uint8 线程ID);
	void			f_setData(void* data, uint8 线程ID = 0);
	std::string     f_构建变量代码(int32 loc);

	bool	f_接入插座是否匹配(E_值类型 type);
	void	f_读取(FILE* f);
	void	f_写入(FILE* f);

	std::wstring		f_getTypeName() { return L"纹理"; }
};

#define DEF_纹理插座(socket)		dynamic_cast<C_纹理插座*>( (socket) )
#define DEF_纹理插座数据(socket)	((S_纹理*)( ((socket))->f_getData(0)) )

#define DEF_创建纹理插座_I(name, ctx)  socket = new C_纹理插座( (name), (ctx) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建纹理插座_O(name, ctx)  socket = new C_纹理插座( (name), (ctx) ); f_add插座(socket, E_插座方向::e_插座Type_输出);






class C_纹理1D插座 : public C_插座基类 {
	S_TexArray* m_默认;
	S_TexArray* m_转换;

	S_纹理 m_内部空纹理;
public:
	C_纹理1D插座(std::wstring name);
	~C_纹理1D插座();

	S_TexArray* m_Value;

	virtual void*	f_getData(uint8 线程ID);
	void			f_setData(void* data, uint8 线程ID = 0);
	std::string     f_构建变量代码(int32 loc);

	void	f_读取(FILE* f);
	void	f_写入(FILE* f);

	std::wstring    f_getTypeName() { return L"[纹理]"; }
};

#define DEF_纹理_1D插座(socket)		dynamic_cast<C_纹理1D插座*>( (socket) )
#define DEF_纹理插座_1D数据(socket)	(( S_TexArray*)((socket)->f_getData(0)) )

#define DEF_创建纹理_1D插座_I(name)  socket = new C_纹理1D插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建纹理_1D插座_O(name)  socket = new C_纹理1D插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);





class C_过程纹理属性插座 : public C_插座基类 {
	S_Props m_默认;
public:
	C_过程纹理属性插座(std::wstring name);
	~C_过程纹理属性插座();

	S_Props* m_TexProp;

	virtual void*	f_getData(uint8 线程ID);
	void			f_setData(void* data, uint8 线程ID = 0);

	void	f_读取(FILE* f);
	void	f_写入(FILE* f);

	std::wstring		f_getTypeName() { return L"纹理属性"; }
};

#define DEF_纹理属性插座(socket)		dynamic_cast<C_过程纹理属性插座*>( (socket) )
#define DEF_纹理属性插座数据(socket, tid)	((S_Props*)( ((socket))->f_getData(tid)) )
#define DEF_创建属性纹理插座_I(name)  socket = new C_过程纹理属性插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建属性纹理插座_O(name)  socket = new C_过程纹理属性插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);




class C_材质插座 : public C_插座基类 {

public:
	C_材质插座(std::wstring name);
	~C_材质插座();

	S_材质* m_Value;

	void*	f_getData(uint8 当前插座连接线ID);
	void	f_setData(void* data, uint8 线程ID = 0);
	bool	f_接入插座是否匹配(E_值类型 type);

	void	f_读取(FILE* f);
	void	f_写入(FILE* f);

	std::wstring		f_getTypeName() { return L"材质"; }
};

#define DEF_材质插座(socket)		dynamic_cast<C_纹理插座*>( (socket) )
#define DEF_材质插座数据(socket, tid)	((S_材质*)(( (socket) )->f_getData(tid)) )

#define DEF_创建材质插座_I(name)  socket = new C_材质插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建材质插座_O(name)  socket = new C_材质插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);



class C_材质_1D插座 : public C_插座基类 {
	S_MaterialArray* m_默认值;
public:
	C_材质_1D插座(std::wstring name);
	~C_材质_1D插座();

	S_MaterialArray* m_Value;
	//std::vector<S_材质*> m_Value;

	void*	f_getData(uint8 当前插座连接线ID);
	void	f_setData(void* data, uint8 线程ID = 0);
	bool	f_接入插座是否匹配(E_值类型 type);

	void	f_读取(FILE* f);
	void	f_写入(FILE* f);

	std::wstring		f_getTypeName() { return L"[材质]"; }
};

#define DEF_材质_1D插座(socket)		dynamic_cast<C_纹理插座*>( (socket) )
#define DEF_材质插座_1D数据(socket, tid)	((S_MaterialArray*)(( (socket) )->f_getData(tid)) )

#define DEF_创建材质_1D插座_I(name)  socket = new C_材质_1D插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建材质_1D插座_O(name)  socket = new C_材质_1D插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);





class C_着色器插座 : public C_插座基类 {
	S_着色* m_默认值;
public:
	C_着色器插座(std::wstring name);
	~C_着色器插座();

	S_着色* m_Value;

	void*	f_getData(uint8 当前插座连接线ID);
	void	f_setData(void* data, uint8 线程ID = 0);
	bool	f_接入插座是否匹配(E_值类型 type);
	//void	f_读取(FILE* f);
	//void	f_写入(FILE* f);
	std::wstring		f_getTypeName() { return L"[着色]"; }
};

#define DEF_着色器插座(socket)		dynamic_cast<C_着色器插座*>( (socket) )
#define DEF_着色器数据(socket, tid)	((S_着色*)(( (socket) )->f_getData(tid)) )

#define DEF_创建着色器插座_I(name)  socket = new C_着色器插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建着色器插座_O(name)  socket = new C_着色器插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);












